package com.wudd.common.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
 

/**
 * 描述：日期工具类
 * @author 吴冬冬
 * @date 2018年11月7日 下午4:03:31  
 * @version V1.0
 */
public class DateUtils {
	/**
	 * 年月日格式
	 */
	private final static String YMD_FORMAT = "yyyyMMdd";
	/**
	 * 年-月-日格式
	 */
	private final static String Ymd_FORMAT = "yyyy-MM-dd";


	/**
	 * 年月日时分秒
	 */
	private final static String YMDHMS_FORMAT = "yyyyMMdd HHmmss";

	/**
	 * 年月日时分秒
	 */
	private final static String YMDHMS2_FORMAT = "yyyyMMddHHmmss";
	/**
	 * 年月日时分秒
	 */
	private final static String YMDHMS_FORMAT2 = "yyyy-MM-dd HH:mm";
	/**
	 * 年月日时分秒
	 */
	private final static String YMDHMS_FORMAT3 = "yyyy-MM-dd HH:mm:ss";

	/**
	 * 年月日时分秒
	 */
	private final static String YMDHMS_FORMAT5 = "yyyy-MM-dd-HH-mm-ss";

	/**
	 * 年月日时分秒
	 */
	private final static String YMDHMS_FORMAT4 = "yyyyMMdd-HH:mm";

	/**
	 * 月日年时分秒
	 */
	private final static String DMYHMS_FORMAT5 = "MM/dd/yyyy HH:mm:ss";

	/**缺省日格式*/
	public static final String DEFAULT_DATE = "DAY";
	
	/**缺省小时格式*/
	public static final String DEFAULT_HOUR = "HOUR";
	
	/**缺省分钟格式*/
	public static final String DEFAULT_MINUTE = "MINUTE";
	
	/**缺省秒格式*/
	public static final String DEFAULT_SECOND = "SECOND";

	 /**
	   * 计算日期时间之间的差值， date1得时间必须大于date2的时间
	   * @version 2011-7-12
	   * @param date1
	   * @param date2
	   * @return {@link Map} Map的键分别为, day(天), hour(小时),minute(分钟)和second(秒)。
	   */
	  public static Map<String, Long> timeDifference(final Date date1, final Date date2){
		  if(date1 == null || date2 == null){
			  throw new NullPointerException("date1 and date2 can't null");
		  }
		  long mim1 = date1.getTime();
		  long mim2 = date2.getTime();
		  if(mim1 < mim2){
			  throw new IllegalArgumentException(String.format("date1[%s] not be less than date2[%s].", mim1 + "", mim2 + ""));
		  }
		  long m = (mim1 - mim2 + 1) / 1000l;
	      long mday = 24 * 3600;
	      final Map<String, Long> map = new HashMap<String, Long>();
	      map.put(DEFAULT_DATE, m / mday);
	      m = m % mday;
	      map.put(DEFAULT_HOUR, (m) / 3600);
	      map.put(DEFAULT_MINUTE, (m % 3600) / 60);
	      map.put(DEFAULT_SECOND, (m % 3600 % 60));
	      return map;
	  }
	
	/**
	 * <p>
	 * 功能说明：字符串转日期,转义失败获取当前日期
	 * </p>
	 * 
	 * @param dateStr
	 *            日期字符串 ，格式：yyyyMMdd hhmmss
	 * @return Date
	 * @throws ParseException 
	 */
	public static Date strToDate(String dateStr) throws ParseException {
		if (StringUtils.isBlank(dateStr))
			return null;
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT);
		Date date = new Date();
		date = sdf.parse(dateStr);
		return date;
	}

	public static Date strToDate5(String dateStr) throws ParseException {
		if (StringUtils.isBlank(dateStr))
			return null;
		SimpleDateFormat sdf = new SimpleDateFormat(DMYHMS_FORMAT5);
		Date date = new Date();
		date = sdf.parse(dateStr);
		return date;
	}

	public static Date strToDate1(String dateStr) throws ParseException {
		if (StringUtils.isBlank(dateStr))
			return null;
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT4);
		Date date = new Date();
		date = sdf.parse(dateStr);
		return date;
	}

	public static String betweenDays(Date beginDate, Date endDate) {
		long s= endDate.getTime()-beginDate.getTime();
		String day = s / (1000) + "秒";
//				s / (1000 * 24 * 60 * 60) + "天";
//		day +=  s % 24 / (1000 * 60 * 60) + "小时";
//		day +=  s %(24*60) / (1000 * 60) + "分钟";
		 

		return day;
	}

	public static Date StringToDate(String dateStr) throws ParseException {
		if (StringUtils.isBlank(dateStr))
			return null;
		SimpleDateFormat sdf = new SimpleDateFormat(Ymd_FORMAT);
		Date date = new Date();
		date = sdf.parse(dateStr);
		return date;
	}

	/**
	 * <p>
	 * 功能说明：字符串转日期,转义失败获取当前日期
	 * </p>
	 * 
	 * @param dateStr
	 *            日期字符串 ，格式：YMDHMS_FORMAT3
	 * @return Date
	 * @throws ParseException 
	 */
	public static Date strToDate3(String dateStr) throws ParseException {
		if (StringUtils.isBlank(dateStr))
			return null;
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT3);
		Date date = new Date();
		date = sdf.parse(dateStr);
		return date;
	}

	/**
	 * <p>
	 * 功能说明：字符串转日期,转义失败获取当前日期
	 * </p>
	 * 
	 * @param dateStr
	 *            日期字符串 ，格式：YMDHMS_FORMAT2
	 * @return Date
	 * @throws ParseException 
	 */
	public static Date strToDate2(String dateStr) throws ParseException {
		if (StringUtils.isBlank(dateStr))
			return null;
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT2);
		Date date = new Date();
		date = sdf.parse(dateStr);
		return date;
	}
	/**
	 * <p>
	 * 功能说明：字符串转日期,转义失败获取当前日期
	 * </p>
	 * 
	 * @param date
	 *            日期字符串 ，格式：YMDHMS_FORMAT3
	 * @return Date
	 */
	public static String strToDate4(Date date) {
		if (date==null)
			return null;
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS2_FORMAT); 
		String dateStr="";
		dateStr = sdf.format(date);
		return dateStr;
	}


	public static String strToDate5(Date date) {
		if (date==null)
			return null;
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT3);
		String dateStr="";
		dateStr = sdf.format(date);
		return dateStr;
	}


	/**
	 * <p>
	 * 功能说明：字符串转日期,转义失败获取当前日期
	 * </p>
	 * 
	 * @param date
	 *            日期字符串 ，格式：YMDHMS_FORMAT3
	 * @return Date
	 */
	public static String dateToStr3(Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT3);
		String dateStr = "";
		dateStr = sdf.format(date);
		return dateStr;
	}

	public static String dateToStr1(Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT);
		String dateStr = "";
		dateStr = sdf.format(date);
		return dateStr;
	}

	/**
	 * yyyy-MM-dd-HH-mm-ss
	 * 
	 * @param date
	 * @return
	 */
	public static String dateToStr5(Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT5);
		String dateStr = "";
		dateStr = sdf.format(date);
		return dateStr;
	}

	public static String dateToStr2(Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT3);
		String dateStr = "";
		dateStr = sdf.format(date);
		return dateStr;
	}

	/**
	 * <p>
	 * 功能说明：字符串转日期,转义失败获取当前日期
	 * </p>
	 * 
	 * @param date
	 *            日期字符串 ，格式：yyyyMMdd hhmmss
	 * @return Date
	 */
	public static String dateToStr(Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat(YMDHMS_FORMAT2);
		String dateStr = "";
		if (date == null)
			return dateStr;
		dateStr = sdf.format(date);
		return dateStr;
	}

	/**
	 * <p>
	 * 功能说明：日期转字符串
	 * </p>
	 * 
	 * @param date
	 *            日期
	 * @param formatStr
	 *            转义格式字符串，如：yyyyMMdd
	 * @return String 日期字符串
	 * @author w
	 */
	public static String dateToStr(Date date, String formatStr) {
		SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
		String dateStr = "";
		if (date == null)
			return dateStr;
		dateStr = sdf.format(date);
		return dateStr;
	}

	/**
	 * <p>
	 * 功能说明：字符串转日期,转义失败返回null
	 * </p>
	 * 
	 * @param dateStr
	 *            日期字符串 ，格式：YMDHMS_FORMAT3
	 * @param formatStr
	 *            转义格式字符串
	 * @return Date
	 * @throws ParseException 
	 */
	public static Date strToDate(String dateStr, String formatStr) throws ParseException {
		Date date = null;
		if (StringUtils.isBlank(formatStr)) {
			return date;
		}
		SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
		date = sdf.parse(dateStr); 
		return date;
	}

	/**
	 * <p>
	 * 功能说明：字符串转日期,转义失败获取当前日期
	 * </p>
	 * 
	 * @param dateStr
	 *            日期字符串，格式：yyyyMMdd
	 * @return Date
	 * @throws ParseException 
	 */
	public static Date strToYMDDate(String dateStr) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat(YMD_FORMAT);
		Date date = new Date();
		date = sdf.parse(dateStr);
		return date;
	}

	public static int getMonth() {
		return Calendar.getInstance().get(Calendar.MONTH) + 1;
	}

	public static int getYear() {
		return Calendar.getInstance().get(Calendar.YEAR);
	}
	
	/**
	 * 获得时间段内所有日历
	 * 
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public static List<Map<String, String>> getDaysWithStartEndDate(Date startDate, Date endDate) {
		List<Map<String, String>> dayList = new ArrayList<Map<String, String>>();
		Calendar cal1 = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		cal1.setTime(startDate);
		cal2.setTime(endDate);
		int startYear = cal1.get(Calendar.YEAR);
		int startMonth = cal1.get(Calendar.MONTH) + 1;
		int startDay = cal1.get(Calendar.DAY_OF_MONTH);
		int endYear = cal2.get(Calendar.YEAR);
		int endMonth = cal2.get(Calendar.MONTH) + 1;
		int endDay = cal2.get(Calendar.DAY_OF_MONTH);
		List<Integer[]> yms = new ArrayList<Integer[]>();
		for (int year = startYear; year <= endYear; year++) {
			for (int month = (year == startYear ? startMonth : 1); month <= (year == endYear ? endMonth : 12); month++) {
				Integer[] ym = new Integer[4];
				ym[0] = year;
				ym[1] = month;
				ym[2] = (year == startYear && month == startMonth ? startDay : 0);
				ym[3] = (year == endYear && month == endMonth ? endDay : 0);
				yms.add(ym);
			}
		}
		for (Integer[] ym : yms) {
			dayList.addAll(getdays(ym));
		}
		return dayList;

	}

	/**
	 * 获得某月的日历
	 * 
	 * @param ym
	 * @return
	 */
	public static List<Map<String, String>> getdays(Integer[] ym) {
		int year = ym[0];
		int month = ym[1];
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.YEAR, year);
		cal.set(Calendar.MONTH, month - 1);
		int maxDays = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
		List<Map<String, String>> days = new ArrayList<Map<String, String>>();
		for (int i = (ym[2] == 0 ? 1 : ym[2]); i <= (ym[3] == 0 ? maxDays : ym[3]); i++) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("year", year + "");
			map.put("month", month + "");
			map.put("day", i + "");
			days.add(map);
		}
		return days;
	}

	/**
	 * 获取字符串格式时间（YYYY-MM-DD HH24:MI:SS）
	 * 
	 * */
	public static String getFullDate(Date date) {
		String current = "";
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		current = format.format(date);
		return current;
	}

	/**
	 * 获取字符串格式时间（YYYY-MM-DD HH24:MI:SS）
	 * 
	 * */
	public static String getShortDate(Date date) {
		String current = "";
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		current = format.format(date);
		return current;
	}

	
	/**
	 * 在当前时间上增加N天
	 * 
	 * */
	public static Date addYears(Date date, int years) throws Exception {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.YEAR, years);
		date = calendar.getTime();
		return date;
	}
	
	/**
	 * 在当前时间上增加N天
	 * 
	 * */
	public static String addYears(String dateStr,String format, int years) throws Exception {
		Date date = strToDate(dateStr, format);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.YEAR, years);
		date = calendar.getTime();
		return DateUtils.dateToStr(date, format);
	}
	
	/**
	 * 在当前时间上增加N天
	 * 
	 * */
	public static Date addDays(Date date, int days) throws Exception {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.DAY_OF_MONTH, days);
		date = calendar.getTime();
		return date;
	}

	

	/**
	 * 在当前时间上增加N小时
	 * 
	 * */
	public static Date addHours(Date date, int hours) throws Exception {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.HOUR_OF_DAY, hours);
		date = calendar.getTime();
		return date;
	}
	
	/**
	 * 在当前时间上增加N分钟
	 * 
	 * */
	public static Date addMinutes(Date date, int minute) throws Exception {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.MINUTE, minute);
		date = calendar.getTime();
		return date;
	}
	
	/**
	 * 在当前时间上增加N秒
	 * 
	 * */
	public static Date addseconds(Date date, int seconds) throws Exception {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.SECOND, seconds);
		date = calendar.getTime();
		return date;
	}

	/**
	 * 获取当前时间
	 * 
	 * @return
	 */
	public static Date getToDate() {
		Calendar cal = Calendar.getInstance();
		return cal.getTime();
	}


	/**
	 * 获取天
	 * 
	 * @return
	 */
	public static int getDay() {
		SimpleDateFormat dd_fm = new SimpleDateFormat("dd");
		Calendar cal = Calendar.getInstance();
		int day = Integer.valueOf(dd_fm.format(cal.getTime()));
		return day;
	}
	
	/**获取本月的第一天*/
	public static String getFirstDayOfMonth(String format)   {  
		SimpleDateFormat dtFormat=new SimpleDateFormat(format); 
        Calendar cal_1=Calendar.getInstance();//获取当前日期   
        cal_1.add(Calendar.MONTH, 0);  
        cal_1.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 
        cal_1.set(Calendar.HOUR_OF_DAY,0);
        cal_1.set(Calendar.MINUTE,0);
        cal_1.set(Calendar.SECOND,0);
        cal_1.set(Calendar.MILLISECOND,0);
        return dtFormat.format(cal_1.getTime());  
	} 
	/**获取本月的最后一天*/
	public static String getLastDayOfMonth(String format) {
		SimpleDateFormat dtFormat=new SimpleDateFormat(format); 
        Calendar cal_1 = Calendar.getInstance();      
        cal_1.set(Calendar.DAY_OF_MONTH, cal_1.getActualMaximum(Calendar.DAY_OF_MONTH)); 
        cal_1.set(Calendar.HOUR_OF_DAY,23);
        cal_1.set(Calendar.MINUTE,59);
        cal_1.set(Calendar.SECOND,59);
        cal_1.set(Calendar.MILLISECOND,999);
        return   dtFormat.format(cal_1.getTime());  
	} 
	/**计算当前时间的 前/后 几个月
	 * @throws ParseException */
	public static long addMonth(Integer month) throws ParseException {
		SimpleDateFormat matter=new SimpleDateFormat("yyyyMM");
	    Calendar calendar = Calendar.getInstance();
	    calendar.add(Calendar.MONTH,month);
	    Date date02 = calendar.getTime();
	    String ss = matter.format(date02);
	    return matter.parse(ss).getTime();
	} 
	
	/**
	 * 
	 * @param day (yyyy-mm-dd)
	 * @return
	 * @throws ParseException
	 */
	public static Long getDaysNum(String day) throws ParseException{
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		Date d1 = df.parse(day);
		Date d2 = new Date();
		long diff = d1.getTime() - d2.getTime();
		long days = diff / (1000 * 60 * 60 * 24);
		return days;
	}
	public static String getWeekOfDateStr(Date date) {      
	    String[] weekOfDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};     
	    Calendar calendar = Calendar.getInstance();      
	    if(date != null){        
	         calendar.setTime(date);      
	    }        
	    int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;   
	    if (w < 0){        
	        w = 0;      
	    }      
	    return weekOfDays[w];   
	}
	
	
	public static Integer getWeekOfDateNum(Date date) {      
	    Calendar calendar = Calendar.getInstance();      
	    if(date != null){        
	         calendar.setTime(date);      
	    }        
	    int w = calendar.get(Calendar.DAY_OF_WEEK) - 1; 
	    if(w==0){
	    	w=7;
	    }
	    if (w < 0){        
	        w = 0;      
	    }      
	    return w;   
	}
	//获取数字对应的周数
		public static String getWeekName(String weekId){
			String a="";
		 switch (weekId) {
			case "1":
				return "周一";
			case "2":
				return "周二";
			case "3":
				return "周三";
			case "4":
				return "周四";
			case "5":
				return "周五";
			case "6":
				return "周六";
			case "7":
				return "周日";
		  }
			   return a;
		}
		
		public static String getWeekIndex(String weekId){
			String a="";
		 switch (weekId) {
			case "周一":
				return "1";
			case "周二":
				return "2";
			case "周三":
				return "3";
			case "周四":
				return "4";
			case "周五":
				return "5";
			case "周六":
				return "6";
			case "周日":
				return "7";
		  }
			   return a;
		}
		
		/**
		 * 获取几天后的日期（yyyy-mm-dd）
		 * @param days
		 * @return
		 */
		@SuppressWarnings("static-access")
		public static String getDayStrByDays(int days){
			Date date=new Date();//取时间
			   Calendar calendar = new GregorianCalendar();
			   calendar.setTime(date);
			   calendar.add(calendar.DATE,days);//把日期往后增加一天.整数往后推,负数往前移动
			   date=calendar.getTime(); //这个时间就是日期往后推一天的结果 
			   SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			   String dateString = formatter.format(date);
			   return dateString;
		}
		
		/**
	     * 日期转星期
	     * 
	     * @param datetime
	     * @return
	     */
		public static String dateToWeek(String datetime) {
	        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
	        String[] weekDays = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
	        Calendar cal = Calendar.getInstance(); // 获得一个日历
	        Date datet = null;
	        try {
	            datet = f.parse(datetime);
	            cal.setTime(datet);
	        } catch (ParseException e) {
	            e.printStackTrace();
	        }
	        int w = cal.get(Calendar.DAY_OF_WEEK) - 1; // 指示一个星期中的某天。
	        if (w < 0)
	            w = 0;
	        return weekDays[w];
	    }
		
		/**
		 * 判断是否是当天
		 * @param date
		 * @return
		 */
		public static boolean isToday(Date date){
		     SimpleDateFormat fmt=new SimpleDateFormat("yyyy-MM-dd");
		     if(fmt.format(date).toString().equals(fmt.format(new Date()).toString())){//格式化为相同格式
		          return true;
		      }else {
		        return false;
		      }
		}         
		
		/**
		 * @Description: 计算某天的开始时间
		 * @param someDay
		 * @return
		 * @author: tianhang.zheng
		 * @date: 2018年8月20日 上午10:33:31
		 */
		public static String getSomeDayStart(Date someDay,String format) {
			SimpleDateFormat dtFormat=new SimpleDateFormat(format); 
	        Calendar calendar=Calendar.getInstance();//获取当前日期   
	        calendar.setTime(someDay);
	        calendar.set(Calendar.HOUR_OF_DAY,0);
	        calendar.set(Calendar.MINUTE,0);
	        calendar.set(Calendar.SECOND,0);
	        calendar.set(Calendar.MILLISECOND,0);
	        return dtFormat.format(calendar.getTime());  
		}
		
		/**
		 * @Description: 计算某天的结束时间
		 * @param someDay
		 * @return
		 * @author: tianhang.zheng
		 * @date: 2018年8月20日 上午10:33:39
		 */
		public static String getSomeDayEnd(Date someDay,String format) {
			SimpleDateFormat dtFormat=new SimpleDateFormat(format); 
	        Calendar calendar=Calendar.getInstance();//获取当前日期   
	        calendar.setTime(someDay);
	        calendar.set(Calendar.HOUR_OF_DAY,23);
	        calendar.set(Calendar.MINUTE,59);
	        calendar.set(Calendar.SECOND,59);
	        calendar.set(Calendar.MILLISECOND,999);
	        return dtFormat.format(calendar.getTime());  
		}
		
		/**
		 * @Description: 获取某天的开始和结束时间List index 0:开始时间  1:结束时间
		 * @param someDay
		 * @return
		 * @author: tianhang.zheng
		 * @date: 2018年8月17日 下午3:32:16
		 */
		public static List<Date> getStartEndTimeForOneDay(Date someDay){
			List<Date> timeList = new ArrayList<>();
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(someDay);
			calendar.set(Calendar.HOUR_OF_DAY,0);
	        calendar.set(Calendar.MINUTE,0);
	        calendar.set(Calendar.SECOND,0);
	        calendar.set(Calendar.MILLISECOND,0);
	        Date dayStart = calendar.getTime();
	        timeList.add(dayStart);
	        calendar.set(Calendar.HOUR_OF_DAY,23);
	        calendar.set(Calendar.MINUTE,59);
	        calendar.set(Calendar.SECOND,59);
//	        calendar.set(Calendar.MILLISECOND,999);
	        Date dayEnd = calendar.getTime();
	        timeList.add(dayEnd);
	        return timeList;
		}

	/**
	 * 两个时间段相差几分钟
	 *
	 * 30秒为界限 四舍五入
	 *
	 * @author: hui.zhao
	 * @date  : 2015年5月13日 下午2:09:54
	 * @param end
	 * @param start
	 * @return
	 */
	public static Long minutesBetweenTimes(Date end, Date start) {
		long endtime = end.getTime();
		long starttme = start.getTime();
		return ((endtime-starttme)/1000+30)/60;
	}


	public static Integer doubleMinuteConvertInteger(Double time){
		Double resultTime = time+0.5;
		return resultTime.intValue();
	}


		 /**
		 * @Description: 计算当日剩余秒数
		 * @param currentDate
		 * @return
		 * @author: tianhang.zheng
		 * @date: 2018年9月18日 下午2:06:04
		 */
		public static Integer getRemainSecondsOneDay(Date currentDate) {
		        Calendar midnight=Calendar.getInstance();
		        midnight.setTime(currentDate);
		        midnight.add(Calendar.DAY_OF_MONTH,1);
		        midnight.set(Calendar.HOUR_OF_DAY,0);
		        midnight.set(Calendar.MINUTE,0);
		        midnight.set(Calendar.SECOND,0);
		        midnight.set(Calendar.MILLISECOND,0);
		        Integer seconds=(int)((midnight.getTime().getTime()-currentDate.getTime())/1000);
		        return seconds;
		    }

	public static List<String> getBeforeSpecialedDayDate(int days,String format){
		List<String> dateList = new ArrayList<>(days);
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		Date now = new Date();
		Calendar calendar= Calendar.getInstance();
		for(int i=1;i<=days;i++){
			calendar.setTime(now);
			calendar.add(Calendar.DATE, -i);
			dateList.add(sdf.format(calendar.getTime()));
		}
		return dateList;
	}

	public static Date getEndTime(Date date){
		Calendar todayEnd = Calendar.getInstance();
		if(date != null) {
			todayEnd.setTime(date);
		}
		todayEnd.set(Calendar.HOUR_OF_DAY, 23);
		todayEnd.set(Calendar.MINUTE, 59);
		todayEnd.set(Calendar.SECOND, 59);
		todayEnd.set(Calendar.MILLISECOND, 999);
		return todayEnd.getTime();
	}
}

